home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / nss / p12.h < prev    next >
C/C++ Source or Header  |  2006-04-20  |  8KB  |  209 lines

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3.  *
  4.  * The contents of this file are subject to the Mozilla Public License Version
  5.  * 1.1 (the "License"); you may not use this file except in compliance with
  6.  * the License. You may obtain a copy of the License at
  7.  * http://www.mozilla.org/MPL/
  8.  *
  9.  * Software distributed under the License is distributed on an "AS IS" basis,
  10.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11.  * for the specific language governing rights and limitations under the
  12.  * License.
  13.  *
  14.  * The Original Code is the Netscape security libraries.
  15.  *
  16.  * The Initial Developer of the Original Code is
  17.  * Netscape Communications Corporation.
  18.  * Portions created by the Initial Developer are Copyright (C) 1994-2000
  19.  * the Initial Developer. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *
  23.  * Alternatively, the contents of this file may be used under the terms of
  24.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  25.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26.  * in which case the provisions of the GPL or the LGPL are applicable instead
  27.  * of those above. If you wish to allow use of your version of this file only
  28.  * under the terms of either the GPL or the LGPL, and not to allow others to
  29.  * use your version of this file under the terms of the MPL, indicate your
  30.  * decision by deleting the provisions above and replace them with the notice
  31.  * and other provisions required by the GPL or the LGPL. If you do not delete
  32.  * the provisions above, a recipient may use your version of this file under
  33.  * the terms of any one of the MPL, the GPL or the LGPL.
  34.  *
  35.  * ***** END LICENSE BLOCK ***** */
  36.  
  37.  
  38. #ifndef _P12_H_
  39. #define _P12_H_
  40.  
  41. #include "secoid.h"
  42. #include "key.h"
  43. #include "secpkcs7.h"
  44. #include "p12t.h"
  45.  
  46. typedef int (PR_CALLBACK * PKCS12OpenFunction)(void *arg);
  47. typedef int (PR_CALLBACK * PKCS12ReadFunction)(void *arg,
  48.                                                unsigned char *buffer, 
  49.                                                unsigned int *lenRead,
  50.                                                unsigned int maxLen);
  51. typedef int (PR_CALLBACK * PKCS12WriteFunction)(void *arg,
  52.                                                 unsigned char *buffer, 
  53.                                                 unsigned int *bufLen,
  54.                                                 unsigned int *lenWritten);
  55. typedef int (PR_CALLBACK * PKCS12CloseFunction)(void *arg);
  56. typedef SECStatus (PR_CALLBACK * PKCS12UnicodeConvertFunction)(
  57.                                  PRArenaPool *arena,
  58.                                  SECItem *dest, SECItem *src,
  59.                                  PRBool toUnicode,
  60.                                  PRBool swapBytes);
  61. typedef void (PR_CALLBACK * SEC_PKCS12EncoderOutputCallback)(
  62.                             void *arg, const char *buf,
  63.                             unsigned long len);
  64. typedef void (PR_CALLBACK * SEC_PKCS12DecoderOutputCallback)(
  65.                             void *arg, const char *buf,
  66.                             unsigned long len);
  67. typedef SECItem * (PR_CALLBACK * SEC_PKCS12NicknameCollisionCallback)(
  68.                                  SECItem *old_nickname,
  69.                                  PRBool *cancel,
  70.                                  void *arg);
  71.  
  72.  
  73.  
  74.  
  75. typedef SECStatus (PR_CALLBACK *digestOpenFn)(void *arg, PRBool readData);
  76. typedef SECStatus (PR_CALLBACK *digestCloseFn)(void *arg, PRBool removeFile);
  77. typedef int (PR_CALLBACK *digestIOFn)(void *arg, unsigned char *buf, 
  78.                                       unsigned long len);
  79.  
  80. typedef struct SEC_PKCS12ExportContextStr SEC_PKCS12ExportContext;
  81. typedef struct SEC_PKCS12SafeInfoStr SEC_PKCS12SafeInfo;
  82. typedef struct SEC_PKCS12DecoderContextStr SEC_PKCS12DecoderContext;
  83. typedef struct SEC_PKCS12DecoderItemStr SEC_PKCS12DecoderItem;
  84.  
  85. struct sec_PKCS12PasswordModeInfo {
  86.     SECItem    *password;
  87.     SECOidTag    algorithm;
  88. };
  89.  
  90. struct sec_PKCS12PublicKeyModeInfo {
  91.     CERTCertificate    *cert;
  92.     CERTCertDBHandle *certDb;
  93.     SECOidTag    algorithm;
  94.     int keySize;
  95. };
  96.  
  97. struct SEC_PKCS12DecoderItemStr {
  98.     SECItem *der;
  99.     SECOidTag type;
  100.     PRBool hasKey;
  101.     SECItem *friendlyName;      /* UTF-8 string */
  102. };
  103.     
  104.  
  105. SEC_BEGIN_PROTOS
  106.  
  107. SEC_PKCS12SafeInfo *
  108. SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext *p12ctxt,
  109.                     CERTCertDBHandle *certDb,
  110.                     CERTCertificate *signer,
  111.                     CERTCertificate **recipients,
  112.                     SECOidTag algorithm, int keysize);
  113.  
  114. extern SEC_PKCS12SafeInfo *
  115. SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext *p12ctxt, 
  116.                  SECItem *pwitem, SECOidTag privAlg);
  117.  
  118. extern SEC_PKCS12SafeInfo *
  119. SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext *p12ctxt);
  120.  
  121. extern SECStatus
  122. SEC_PKCS12AddPasswordIntegrity(SEC_PKCS12ExportContext *p12ctxt,
  123.                    SECItem *pwitem, SECOidTag integAlg);
  124. extern SECStatus
  125. SEC_PKCS12AddPublicKeyIntegrity(SEC_PKCS12ExportContext *p12ctxt,
  126.                 CERTCertificate *cert, CERTCertDBHandle *certDb,
  127.                 SECOidTag algorithm, int keySize);
  128.  
  129. extern SEC_PKCS12ExportContext *
  130. SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn, void *pwfnarg,  
  131.                   PK11SlotInfo *slot, void *wincx);
  132.  
  133. extern SECStatus
  134. SEC_PKCS12AddCert(SEC_PKCS12ExportContext *p12ctxt, 
  135.           SEC_PKCS12SafeInfo *safe, void *nestedDest,
  136.           CERTCertificate *cert, CERTCertDBHandle *certDb,
  137.           SECItem *keyId, PRBool includeCertChain);
  138.  
  139. extern SECStatus
  140. SEC_PKCS12AddKeyForCert(SEC_PKCS12ExportContext *p12ctxt, 
  141.             SEC_PKCS12SafeInfo *safe, 
  142.             void *nestedDest, CERTCertificate *cert,
  143.             PRBool shroudKey, SECOidTag algorithm, SECItem *pwitem,
  144.             SECItem *keyId, SECItem *nickName);
  145.  
  146. extern SECStatus
  147. SEC_PKCS12AddCertAndKey(SEC_PKCS12ExportContext *p12ctxt, 
  148.             void *certSafe, void *certNestedDest, 
  149.             CERTCertificate *cert, CERTCertDBHandle *certDb,
  150.             void *keySafe, void *keyNestedDest, 
  151.             PRBool shroudKey, SECItem *pwitem, SECOidTag algorithm);
  152.  
  153. extern SECStatus
  154. SEC_PKCS12AddDERCertAndEncryptedKey(SEC_PKCS12ExportContext *p12ctxt, 
  155.             void *certSafe, void *certNestedDest, SECItem *derCert,
  156.             void *keySafe, void *keyNestedDest, 
  157.             SECKEYEncryptedPrivateKeyInfo *epki, char *nickname);
  158.  
  159. extern void *
  160. SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext *p12ctxt,
  161.                    void *baseSafe, void *nestedDest);
  162.  
  163. extern SECStatus
  164. SEC_PKCS12Encode(SEC_PKCS12ExportContext *p12exp, 
  165.          SEC_PKCS12EncoderOutputCallback output, void *outputarg);
  166.  
  167. extern void
  168. SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext *p12exp);
  169.  
  170. extern SEC_PKCS12DecoderContext *
  171. SEC_PKCS12DecoderStart(SECItem *pwitem, PK11SlotInfo *slot, void *wincx,
  172.                digestOpenFn dOpen, digestCloseFn dClose,
  173.                digestIOFn dRead, digestIOFn dWrite, void *dArg);
  174.  
  175. extern SECStatus
  176. SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext *p12dcx,
  177.                            SECPKCS12TargetTokenCAs tokenCAs);
  178.  
  179. extern SECStatus
  180. SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext *p12dcx, unsigned char *data,
  181.             unsigned long len);
  182.  
  183. extern void
  184. SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext *p12dcx);
  185.  
  186. extern SECStatus
  187. SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext *p12dcx);
  188.  
  189. extern SECStatus
  190. SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext *p12dcx,
  191.                   SEC_PKCS12NicknameCollisionCallback nicknameCb);
  192.  
  193. extern SECStatus
  194. SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext *p12dcx);
  195.  
  196. CERTCertList *
  197. SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext *p12dcx);
  198.  
  199. SECStatus
  200. SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext *p12dcx);
  201.  
  202. SECStatus
  203. SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext *p12dcx,
  204.                              const SEC_PKCS12DecoderItem **ipp);
  205.  
  206. SEC_END_PROTOS
  207.  
  208. #endif
  209.